<template>
    <div class="wordContainer">
        <el-dialog
            title="相关文档"
            :visible.sync="dialogWord"
            width="50%"
            :before-close="handleClose">
            
                <el-table :data="wordList" :show-header="false" style="width: 100%;font-size:14px;">
                    <el-table-column width="40">
                        <template slot-scope="scope">
                            <div class="notice-tag" v-bind:class="'notice-tag-'+(scope.$index+1)"><i class="iconfont icon-tongzhifawen_A"></i></div>
                        </template>
                    </el-table-column>
                    <el-table-column show-overflow-tooltip>
                        <template slot-scope="scope">
                            <div class="todo-item">
                                <a href="#" title="" @click="openMenuFunction(scope.row)">{{scope.row.name}}</a>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column width="102">
                        <template slot-scope="scope">
                            <div class="todo-date">{{scope.row.publishTime}}</div>
                        </template>
                    </el-table-column>
                </el-table>
            <span slot="footer" class="dialog-footer">
                <el-button @click="handleClose">取 消</el-button>
                <el-button type="primary" @click="handleClose">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import { createNamespacedHelpers } from 'vuex';
import bus from '../../../common/bus';
import { wordContent } from '../data/Content.js';
import appUtil from '~/assets/utils/appUtil.js';
const { mapState } = createNamespacedHelpers('homeModule');
export default {
    name: 'WordDialog',
    props:['dialogWord'],
    data () {
        return {
            wordList:[],
            articleDetail:'./articleDetail.html',
        };
    },
    created(){
        this.getWordList();
    },
    computed:{
        ...mapState(['userDetail']),

    }, 
    methods: {
        // 关闭
        handleClose(){
            // 子组件调用父组件的方法
            this.$parent.closeALL();
        },
        getWordList(){
            this.$axios.get(wordContent.wordUrl).then(res => {
                this.getList(res.data[0]);
                this.config = res.data[0];
                this.showTemplate = true;
            });
        },
        getList(param){
            console.log(this.userDetail);
            let data = {
                categoryId:param.categoryId,
                userId:appUtil.getSes('userId'),
                deptCodes:this.userDetail.deptId ||'',
                roleIds:this.userDetail.roles[0].roleId ||'',
                agcyCodes:this.userDetail.agencyId || '',
                divCodes:this.userDetail.mofDivId || '',
                status:'1',
                ps:10,
                pn:1,
                frontId:'1' //需要通过失效时间过滤
            };
            this.$axios.get('/ptp-cms/cmscontent/getContentByOne',{params:data})
                .then(res => {
                    if(res.data.code === -1){
                        return;
                    }
                    this.wordList = res.data.data.dataList;
                });
        },
        // 打开详情页面
        openMenuFunction(item){
            this.$parent.closeALL();
            let url = this.articleDetail+'?typeId=' + item.typeId + '&articleId='+ item.id;
            let menu = {
                url:url,
                name:this.config.name,
                isNew:false // 是否在新页面打开
            };     
            bus.$emit('openMenu',menu);
        },
        
    },
};
</script>

<style lang="scss" scoped>
.wordContainer{
     .el-dialog__body{
        height: 300px;
        overflow-y: auto;
    }
}
</style>
